import request from '@/config/axios'

// 巨量授权码配置 VO
export interface AuthcodeConfigVO {
  id: number // 主键ID
  accountType: number // 账户类型：1-主账户，2-千川，3-AD，4-本地推，5-钱包
  authCode: string // 授权码
  appId: string // 应用ID
  appSecret: string // 应用密钥
  remark: string // 备注
}

// 巨量授权码配置 API
export const AuthcodeConfigApi = {
  // 查询巨量授权码配置分页
  getAuthcodeConfigPage: async (params: any) => {
    return await request.get({ url: `/juliang/authcode-config/page`, params })
  },

  // 查询巨量授权码配置详情
  getAuthcodeConfigById: async (id: number) => {
    return await request.get({ url: `/juliang/authcode-config/getById?id=` + id })
  },

  // 刷新缓存
  refreshToken: async (id: number) => {
    return await request.get({ url: `/juliang/authcode-config/refreshToken?id=` + id })
  },

  // 新增巨量授权码配置
  createAuthcodeConfig: async (data: AuthcodeConfigVO) => {
    return await request.post({ url: `/juliang/authcode-config/create`, data })
  },

  // 修改巨量授权码配置
  updateAuthcodeConfig: async (data: AuthcodeConfigVO) => {
    return await request.post({ url: `/juliang/authcode-config/update`, data })
  },

  // 修改巨量授权码配置状态
  updateAuthcodeConfigStatus: async (id: number, status: number) => {
    const data = {
      id,
      status
    }
    return await request.post({ url: `/juliang/authcode-config/updateStatus`, data: data })
  },

  // 删除巨量授权码配置
  deleteAuthcodeConfigById: async (id: number) => {
    return await request.get({ url: `/juliang/authcode-config/delete?id=` + id })
  },

  // 导出巨量授权码配置 Excel
  exportAuthcodeConfig: async (params) => {
    return await request.download({ url: `/juliang/authcode-config/export-excel`, params })
  },
}
